package comm.hg.fitter;


import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class guoLvQi1 implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException {
        //强转为http请求、响应
        HttpServletRequest req1=(HttpServletRequest) req;
        HttpServletResponse resp1=(HttpServletResponse) resp;
        String user = String.valueOf(req1.getSession().getAttribute("uid"));
        if("".equals(user) || "null".equals(user)){
            resp1.sendRedirect("login.html");
        }else{
            chain.doFilter(req1, resp1);
        }
    }

    @Override
    public void destroy() {

    }
}
